import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'

// 导入全局样式
import '@/assets/css/global.css'

//导入rem
import '@/assets/js/flexible.js'

//导入字体图标
import '@/assets/fonts/iconfont.css'

//导入树形表格插件
const TreeTable = () => import('vue-table-with-tree-grid');
// import TreeTable from 'vue-table-with-tree-grid';

//导入文本编辑器
import VueQuillEditor from 'vue-quill-editor'
//导入文本编辑器样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

//导入网络请求
import axios from 'axios'
//全局配置组件
Vue.component('tree-table', TreeTable);
//全局配置文本编辑器样式
Vue.use(VueQuillEditor);

//配置请求根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
//配置拦截器
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token');
  return config;
})
Vue.prototype.$http = axios
Vue.config.productionTip = false

//格式化输出日期的过滤器
Vue.filter('dataFormat', function (originVal) {
  const date = new Date(originVal);
  const year = date.getFullYear();
  const month = (date.getMonth() + 1 + '').padStart(2, '0');
  const day = (date.getDay() + '').padStart(2, '0');
  const hours = (date.getHours() + '').padStart(2, '0');
  const minute = (date.getMinutes() + '').padStart(2, '0');
  const seconds = (date.getSeconds() + '').padStart(2, '0');
  return year + '-' + month + '-' + day + ' ' + hours + ':' + minute + ':' + seconds;

})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
